#include <stdio.h>
#include <unistd.h>    
#include <stdlib.h>    
#include <sys/types.h>    
#include <sys/wait.h>    
    
int main()    
{    
    printf("testexec start...\n");    
    pid_t id = fork();    
    if (id == 0)    
    {    
      // child    
      char *const argv[] = {"myprocess", "-a", "-b", NULL};
      // char *const envp[] = {"HAHA=123", "HEHE=456", NULL};
      extern char** environ;
      putenv("HELLO=1111111111111111");
      execvpe("./myprocess", argv, environ);
      // execv("/usr/bin/ls", argv);
      // execl("/usr/bin/lss", "-a", "-l", "--color", NULL);    
      exit(1); // 代码运行到这里，说明替换失败
    }    
    // father    
    int status = 0;    
    pid_t rid = waitpid(id, &status, 0);    
    if (rid > 0)    
    {    
      // 等待成功    
      printf("father wait sucess, child exit_code: %d\n", WEXITSTATUS(status));    
    }    
    printf("testexec end...\n");    
}   
